package cn.ytxy.ivos.geofence.controller;


import cn.ytxy.ivos.base.response.JsonResult;
import cn.ytxy.ivos.geofence.pojo.dto.GeofenceParam;
import cn.ytxy.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.ytxy.ivos.geofence.pojo.vo.GeofenceVO;
import cn.ytxy.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName GeofenceController
 * @Description TODO
 * @Author renhong~Deng
 * @Date 2025/5/8 15:15
 * @Version 1.0
 */

@Slf4j
@RestController
@RequestMapping("/v1/geofence/")
public class GeofenceController {

    @Autowired
    GeofenceService geofenceService;

    @GetMapping("/select")
    public JsonResult selectGeofence(GeofenceQuery geofenceQuery){
        log.info("查询电子围栏数据GeofenceQuery={}",geofenceQuery);
        List<GeofenceVO> geofenceVOS = geofenceService.selectGeofence(geofenceQuery);

        return JsonResult.ok(geofenceVOS);
    }

    @PostMapping("/save")
    public JsonResult saveGeofence(GeofenceParam geofenceParam){
        log.info("保存电子围栏数据GeofenceParam={}",geofenceParam);
        geofenceService.saveGeofence(geofenceParam);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult deleteGeofence(@PathVariable Long id){
        log.info("删除电子围栏数据id={}",id);
        geofenceService.deleteGeofence(id);
        return JsonResult.ok();
    }
}
